% V20210224 - 14.5 JS INCLUDE "GW.bas" % Create a page. p = GW_NEW_PAGE() % Prepare title bar string. Title$ = GW_ADD_BAR_TITLE$("Simple JS Example") % Add title to page. GW_ADD_TITLEBAR(p, Title$) % Add a textbox and a button. txt = GW_ADD_TEXTBOX(p, "--") btn = GW_ADD_BUTTON(p, "Get the WebView User Agent", "UA") % Show the page. GW_RENDER(p) DO % Wait for user action. r$ = GW_WAIT_ACTION$() % User clicked on "Get user agent" IF r$ = "UA" % Disable the button GW_DISABLE(btn) % Run a script to send built-in javascript variable from WebView to BASIC! JS("RFO(navigator.userAgent)") % Note: RFO() is the built-in function in GW to communicate from the HTML world to BASIC! % Get the variable ua$ = GW_WAIT_ACTION$() % Show it in the textbox GW_MODIFY(txt, "text", ua$) ENDIF % Wait that the BACK key is pressed. UNTIL r$ = "BACK" END "End of JS Simple example."